package com.ruoyi.project.remake.controller;

import java.util.List;

import org.apache.poi.ss.formula.functions.T;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.remake.domain.TRemakeCaseDetails;
import com.ruoyi.project.remake.service.ITRemakeCaseDetailsService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 翻拍病例详情Controller
 *
 * @author 孙山伟
 * @date 2020-12-15
 */
@RestController
@RequestMapping("/remake/remakeCaseDetails")
public class TRemakeCaseDetailsController extends BaseController
{
    @Autowired
    private ITRemakeCaseDetailsService tRemakeCaseDetailsService;

    /**
     * 查询翻拍病例详情列表
     */
    @PreAuthorize("@ss.hasPermi('remake:remakeCaseDetails:list')")
    @GetMapping("/list")
    public TableDataInfo list(TRemakeCaseDetails tRemakeCaseDetails)
    {
        startPage();
        List<TRemakeCaseDetails> list = tRemakeCaseDetailsService.selectTRemakeCaseDetailsList(tRemakeCaseDetails);
        return getDataTable(list);
    }

    /**
     * 导出翻拍病例详情列表
     */
    @PreAuthorize("@ss.hasPermi('remake:remakeCaseDetails:export')")
    @Log(title = "翻拍病例详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TRemakeCaseDetails tRemakeCaseDetails)
    {
        List<TRemakeCaseDetails> list = tRemakeCaseDetailsService.selectTRemakeCaseDetailsList(tRemakeCaseDetails);
        ExcelUtil<TRemakeCaseDetails> util = new ExcelUtil<TRemakeCaseDetails>(TRemakeCaseDetails.class);
        return util.exportExcel(list, "remakeCaseDetails");
    }
    /**
     * 导出翻拍病例详情列表
     */
    @PreAuthorize("@ss.hasPermi('remake:remakeCaseDetails:export')")
    @Log(title = "翻拍病例详情", businessType = BusinessType.EXPORT)
    @GetMapping("/exportPDF/{id}")
    public AjaxResult exportPDF(@PathVariable Long id)
    {
        tRemakeCaseDetailsService.toPDF(id);

        return  AjaxResult.success();
    }
    /**
     * 获取翻拍病例详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('remake:remakeCaseDetails:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tRemakeCaseDetailsService.selectTRemakeCaseDetailsById(id));
    }

    /**
     * 新增翻拍病例详情
     */
    @PreAuthorize("@ss.hasPermi('remake:remakeCaseDetails:add')")
    @Log(title = "翻拍病例详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TRemakeCaseDetails tRemakeCaseDetails)
    {
        return AjaxResult.success(tRemakeCaseDetailsService.insertTRemakeCaseDetails(tRemakeCaseDetails));
    }

    /**
     * 修改翻拍病例详情
     */
    @PreAuthorize("@ss.hasPermi('remake:remakeCaseDetails:edit')")
    @Log(title = "翻拍病例详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TRemakeCaseDetails tRemakeCaseDetails)
    {
        return toAjax(tRemakeCaseDetailsService.updateTRemakeCaseDetails(tRemakeCaseDetails));
    }

    /**
     * 删除翻拍病例详情
     */
    @PreAuthorize("@ss.hasPermi('remake:remakeCaseDetails:remove')")
    @Log(title = "翻拍病例详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tRemakeCaseDetailsService.deleteTRemakeCaseDetailsByIds(ids));
    }
}
